/*
 *  IncrementalAlgorithm.h
 *  IncrementalAlgorithmSerial
 *
 *  Created by Roman Kutlak on 30/10/2010.
 *  Copyright 2010 Roman Kutlak. All rights reserved.
 *
 */

#ifndef _INCREMENTAL_ALGORITHM_H_
#define _INCREMENTAL_ALGORITHM_H_

#include <list>
#include <string>

#include "Algorithm.h"
#include "AlgorithmFunctions.h"
#include "KnowledgeBase.h"


#ifdef DEBUG
#define IA_DEBUG 0
#endif

namespace kutlak {
namespace roman {
namespace gre {
    
    /*! \brief Implementation of the Incremental Algorithm by 
     * Dale and Reiter (1995). The class is an abstract class. 
     * The actual algorithm can be parallel or serial.
     * Any implementation of the IA should implement 
     * the functions in this class.
     */
    class IncrementalAlgorithm : public Algorithm {
    public:
        //! \typedef Definition of the type of the preference order.
        typedef std::vector<Vindex_t> PrefOrderT;
        
        /*! The default constructor is not used as this is an abstract class.
         *  The algorithm takes an optional path to a KnowledgeBase.
         */
        IncrementalAlgorithm(const pKnowledgeBase& kb = pKnowledgeBase(),
                             const pOntology& ontology = pOntology());
        
        IncrementalAlgorithm(const IncrementalAlgorithm& from) = delete;
        IncrementalAlgorithm& operator=(const IncrementalAlgorithm& rhs) = delete;
        
        virtual ~IncrementalAlgorithm();
        
#pragma mark -
#pragma mark operations
        
        //! \brief the method generates a referring expression for an entity.
        virtual RefExp MakeReferringExpression(const EntityPtrT& referent,
                                               ContainerT distractors);
        
        virtual RefExp MakeReferringExpression(const std::string& name);
        
        //! Method returns the currently used PO.
        virtual PrefOrderT PreferenceOrder();
        
        //! Method sets new PO.
        virtual void SetPreferenceOrder(const PrefOrderT& po);
        
        /*! Method creates a default PO.
         *  Check that referent is not null if used KB->EntityPtrByName()
         */
        virtual PrefOrderT CreatePreferenceOrder(const Entity& referent);
        
    protected:
        PrefOrderT mPreferenceOrder; //!< Preference order used by the algorithm.
    };
}
}
}

#endif
